<template>
  <div id='homeSwiper' class='homeSwiper'>
    <swiper ref="swiper" v-if="banners.length">
      <swiper-item v-for="(item,index) in banners" :key="index">
        <a :href="item.link">
          <img :src="item.image" alt="" :title="item.title" @load="imageLoad">
        </a>
      </swiper-item>
    </swiper>
  </div>


</template>

<script>
  import {
    Swiper,
    SwiperItem
  } from '../../../components/common/swiper'
  export default {
    name: 'homeSwiper',
    props: { // 父辈向子辈传参
      banners: {
        type: Array,
        default () {
          return []
        }
      }
    },
    data() {
      return {
        isLoad: false
      }
    },
    components: { // 组件的引用
      Swiper,
      SwiperItem
    },
    methods: {
      imageLoad() {
        if (!this.isLoad) {
          this.$emit('swiperImageLoad')
        }
        this.isLoad = true

      }

    },
    created() { // 实例被创建之后执行代码

    },
    computed: { // 计算属性

    },
    mounted() { // 页面进入时加载内容

    },
    watch: { // 监测变化

    }
  }

</script>
<style scoped>


</style>
